-
Notifications
You must be signed in to change notification settings - Fork 539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add docker resource detector #931
feat: add docker resource detector #931
Conversation
detectors/node/opentelemetry-resource-detector-docker/package.json
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,58 @@ | |||
{ | |||
"name": "@opentelemetry/resource-detector-docker", | |||
"version": "1.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure we can release directly as 1.0 ? waiting for other maintainers input on this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would definitely prefer to start with 0.1.0
detectors/node/opentelemetry-resource-detector-docker/package.json
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the detector itself looks good to me, you'll need to fix the CLA though
Codecov Report
@@ Coverage Diff @@
## main #931 +/- ##
==========================================
- Coverage 95.91% 95.82% -0.09%
==========================================
Files 13 15 +2
Lines 856 887 +31
Branches 178 182 +4
==========================================
+ Hits 821 850 +29
- Misses 35 37 +2
|
…hee11/opentelemetry-js-contrib into add-docker-cgroup-containerid updating local with remote changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you'll also need to add there: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/.release-please-manifest.json so it can be automatically published
I think this isn't true anymore with release-please v3 |
Just cleaning out some lint issues - waiting for jobs to run - @dyladan @vmarchaud I appreciate the review on this - thank you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome job! Thanks.
As Daniel mentioned, editing release-please-manifest
is not required anymore. Please revert the change.
detectors/node/opentelemetry-resource-detector-docker/src/detectors/DockerCGroupV1Detector.ts
Outdated
Show resolved
Hide resolved
Signed-off-by: abhinav mathur <[email protected]>
…hee11/opentelemetry-js-contrib into add-docker-cgroup-containerid updating with master
Signed-off-by: abhinav mathur <[email protected]>
@Flarna my bad - pushed - thanks |
[SemanticResourceAttributes.CONTAINER_ID]: containerId || '', | ||
}); | ||
} catch (e) { | ||
diag.warn('Process is not running on a supported docker version', e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be warn
? I think it's valid. User should be able to install a resource detector and have it working only when relevant IMO.
I suggest differentiating between 2 cases:
- "no docker" case which should report
info
and not report the error in the message - some unexpected exception was thrown -
error
and includ the error in the message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So - the reason for this is - if you are installing DockerResourceV1Detector - that would mean - you are adding this dependency assuming you have v1 version running - hence the warning !
As this dependency would be of no use if it did get them the container id - hence we need to warn them that they need have a diff docker version running.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment on the other thread
detectors/node/opentelemetry-resource-detector-docker/src/detectors/DockerCGroupV1Detector.ts
Outdated
Show resolved
Hide resolved
if (e instanceof Error) { | ||
errorMessage = e.message; | ||
diag.warn( | ||
`Docker CGROUP V1 Detector failed to read container ID: ${errorMessage}` | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the previous comment. If the file is missing, I suggest to not log warn
since it's valid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a way to let the user know that their dockerV1Detector is not doing as they hoped. I am wondering if their a another way - do you have any suggestions ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if including a resource detector means that the user is expecting that resource to be present.
2 Examples:
- If the user installs an aws detector and then runs his service locally, I wouldn't expect any warnings to be printed to log as this is completely valid and the message will be confusing. Maybe the service is running inside a docker in production but not in other environments.
- If someone creates a distribution of OpenTelemetry and includes many detectors, the expectation (as far as I am aware) is that only the relevant detectors will be applied. Detectors that are not relevant should be silently ignored. This is the way instrumentations are handled: if someone installs the
@opentelemetry/auto-instrumentations-node
package with all instrumentations, and then his app does not requireredis
package, theninstrumentation-redis
will just not load with no warning to diag channel
I think emitting it as info
makes more sense, something like: "Docker CGROUP V1 Detector did not identify running inside a docker container, no docker attributes will be added to resource".
This is for the case that the file does not exist. If the file exists but exception is thrown for any other reason, I would expect an error
with message that includes the errorMessage
.
This is my take on it, but I'm open for other opinions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quoting from the DiagLogger
interface:
/**
* Log a warning scenario to inform the developer of an issues that should be investigated.
* The requested operation may or may not have succeeded or completed.
*/
warn: DiagLogFunction;
I think when the file is missing it doesn't mean that the developer should investigate anything but only be informed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very helpful - thank you for taking the time and helping me out with this. I appreciate it.
Addressed.
detectors/node/opentelemetry-resource-detector-docker/src/detectors/DockerCGroupV1Detector.ts
Show resolved
Hide resolved
detectors/node/opentelemetry-resource-detector-docker/src/detectors/DockerCGroupV1Detector.ts
Outdated
Show resolved
Hide resolved
detectors/node/opentelemetry-resource-detector-docker/test/DockerCGroupv1Detector.test.ts
Outdated
Show resolved
Hide resolved
detectors/node/opentelemetry-resource-detector-docker/test/DockerCGroupv1Detector.test.ts
Outdated
Show resolved
Hide resolved
readStub = sinon | ||
.stub(DockerCGroupV1Detector, 'readFileAsync' as any) | ||
.onSecondCall() | ||
.rejects(errorMsg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the motivation to return an object and not directly an Error
?
I did not check but guess the fs
functions returns an Error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
motivation is to keep it same as implementation where we are return an error obj.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I misunderstand you, but the test uses:
const errorMsg = {
fileNotFoundError: new Error('cannot file in the path}'),
};
And it will not return an error, but an object with one key named fileNotFoundError
which is an Error
.
Is it consistent with what fs
returns on err
?
I would expect it to be something like:
.rejects(new Error('foo bar'));
detectors/node/opentelemetry-resource-detector-docker/src/detectors/DockerCGroupV1Detector.ts
Outdated
Show resolved
Hide resolved
Signed-off-by: abhinav mathur <[email protected]>
Hello @blumamir |
}); | ||
|
||
describe('Supported docker - Container ID ', () => { | ||
it('should return a emoty resource - docker cgroup v1 detector', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: emoty
-> empty
:)
detectors/node/opentelemetry-resource-detector-docker/test/DockerCGroupv1Detector.test.ts
Show resolved
Hide resolved
readStub = sinon | ||
.stub(DockerCGroupV1Detector, 'readFileAsync' as any) | ||
.onSecondCall() | ||
.rejects(errorMsg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I misunderstand you, but the test uses:
const errorMsg = {
fileNotFoundError: new Error('cannot file in the path}'),
};
And it will not return an error, but an object with one key named fileNotFoundError
which is an Error
.
Is it consistent with what fs
returns on err
?
I would expect it to be something like:
.rejects(new Error('foo bar'));
Signed-off-by: abhinav mathur <[email protected]>
…hee11/opentelemetry-js-contrib into add-docker-cgroup-containerid updating master
…rning to info Signed-off-by: abhinav mathur <[email protected]>
@blumamir I have addressed your comments and pushed the changes. Let me know if there is anything else. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. thanks for the patient and for addressing everything
@blumamir Thank you, feel free to merge. |
Thanks for the contribution, @abhee11(first one, I believe), 🎉, and everyone for the thorough feedback. |
Which problem is this PR solving?
Short description of the changes
Checklist
npm run test-all-versions
for the edited package(s) on the latest commit if applicable.